package com.sfh.cpc.home.fragment;

import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.sfh.cpc.BaseSwipeRefreshMoreLayoutFragment;
import com.sfh.cpc.com.entity.EUser;
import com.sfh.cpc.com.entity.RspPage;
import com.sfh.cpc.com.server.INoteServer;
import com.sfh.cpc.home.adapter.WealthAdapter;
import com.sfh.cpc.home.model.RankingModel;
import com.sfh.lib.AppCacheManager;
import com.sfh.lib.mvvm.annotation.LiveDataMatch;

/**
 * 功能描述:总财力排名
 *
 * @author SunFeihu 孙飞虎
 * @date 2018/9/4
 */
public class UserWealthPageFragment extends BaseSwipeRefreshMoreLayoutFragment<RankingModel>  {

    public static UserWealthPageFragment newFragment() {
        return new UserWealthPageFragment();
    }

    @Override
    public String getName() {
        return "财力";
    }

    @Override
    public BaseQuickAdapter getAdapter() {
        return new WealthAdapter();
    }

    @Override
    public void loadPage(int nowPage) {
        this.getViewModel().pageWealth(nowPage);
    }

    @LiveDataMatch
    public void onPageSuccess(RspPage<EUser> data) {
        super.onPageData(data);
    }

    @Override
    public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
        INoteServer noteServer = AppCacheManager.getCache(INoteServer.class.getSimpleName(),INoteServer.class);
        if (noteServer != null){
            EUser user = (EUser) adapter.getItem(position);
            noteServer.openUserNote(getContext(),user.getUserId());
        }
    }
}
